ScriptLink DeveloperUs Kit
Scott L Sbihli
Procter & Gamble
exotics@eecs.umich.edu

THIS ARTICLE WAS FIRST PUBLISHED IN PDA DEVELOPERS (FORMERLY PIE DEVELOPERS)
MAGAZINE. COPYRIGHT (C) 1994 BY CREATIVE DIGITAL SYSTEMS. ALL RIGHTS RESERVED.
CONTACT CREATIVE DIGITAL SYSTEMS AT CDS@NETCOM.COM FOR MORE INFORMATION. 

Rating	4 1/2 (on a scale of 5)
Pros	Easy to integrate, limitless possibilities
Cons	2K packet limit
Price	SDK (10 Clients, 1 Server): $450
	Additional server or 10-client pack: $300
	Site and Volume Licenses Available

	Momentum Pty.. Ltd.
	P.O. Box 271
	Greenwood 6024
	Australia
	+61.9.483.2649
	+61.9.227.5447 (fax)
	momentum@dialix.oz.au

When I first read about ScriptLink in PIE Developers magazine, I thought to
myself, RBeing able to control Mac applications from the Newton would be
interesting, novel.S After I received the package in the mail and started
reading the accompanying documentation I got greatly excited. Fantastic
visions of undiscovered software country danced in my head. This developerUs
package would be the answer to all of my research groupUs Newton troubles,
not to mention that this product could spawn new software companies
single-handedly. Mind you, I write this paragraph even before IUve tested the
package. Now that's confidence.

Apple What?
I certainly realize that the majority of you who are reading this article
know about AppleScript and probably have programmed with it, but for the rest
you, let me explain what it is. In a ceaseless effort to integrate
applications and data on the Macintosh, Apple created a powerful scripting
language called AppleScript that runs under System 7. If you think of a
Macintosh application as a tile in a bathroom, then AppleScript is the grout
that connects the tiles. An application is considered scriptable if it
accepts Apple Events. Apple Events are generated from AppleScripts. Got that?
The whole idea is that you, as a user, can create easy, but powerful scripts
to control applications. For instance, you could create a script that opens a
database, queries it for data, and sends the results to a graphing program
for visualization.  
	Enter the wireless age. Imagine a version of Apple Remote Access for the
Newton. It dials a PCMCIA modem for access to an AppleTalk network. A
salesman in the field, using a Newton, could receive sales quotes, detailed
product information or pricing via ScriptLink and a scriptable database on
the Macintosh. This product could make some of NewtonUs memory limitations
moot. Wireless makes for some very interesting software scenarios. I digress.

The Sum of the Parts
ScriptLink by Momentum Pty. Ltd. is an application for the Newton which
allows you to control Apple-scriptable Macintosh applications (see Figure 1).
The software contains both a Macintosh and Newton portion. The ScriptLink
server, which runs on a Macintosh, waits for script commands to come from one
or more ScriptLink clients (Newtons) via an AppleTalk connection. As it
receives scripts, it executes those scripts on the Mac, packages the results
and sends them to the Newton. The Newton can do anything it likes with the
results.

All For One Low Price
What I received from Momentum was definitely not what I had expected.
Considering that this is a fairly expensive developerUs product, I had
anticipated a weighty cardboard box with volumes of information on using
ScriptLink PJthe user guide spanned a mere 40 pages. Great, another
developerUs product with terse, unreadable documentation. 

The Instructions
As I sat at my Mac and installed the software, which comes on one high
density disk, I started reading the developerUs guide. It starts with RAbout
This GuideS and includes a subheading titled RAudience.S Now IUve started to
lose my apprehensions. It seems as if a significant amount of time was spent
writing the manual. 
	The documentation covers installation and configuration of both the
server and client pieces of the software. The next section is a reference
guide with a list of all of the available functions you can use.  Following
the reference chapter is a step-by-step instruction guide for creating and
controlling connections. In addition, the manual describes the sample code
that accompanies the product and has information on troubleshooting and
debugging. Overall, the documentation is extremely well done and as an added
bonus fits in 40 pages.

The Client and Server
The ScriptLink Server needs to run continuously on a Macintosh. It occupies
128K on disk and should be placed in the Startup folder so that it is always
available. It patiently waits for Newtons to connect and send it
AppleScripts. The Server has security functions to protect your Macintosh
from destructive, wireless Newton users (it could happen). You may set the
Server to not allow anyone access, allow everyone access, use a simple user
name/password scheme, or control access using AppleScript. With the latter
method you execute a AppleScript, which can do anything, to authenticate the
user. The important thing to remember is that the script should return TRUE
if access is given, nil otherwise.
	The ScriptLink client, which runs on a Newton, uses less than 30K. Though
it displays an icon in the Extras folder, you do not click on it. Think of it
as a function library that you access via NewtonScript. The library consists
of eight functions and callbacks. They handle connections, data transfers,
status inquiries, callbacks and disconnections.
	The connection between the client and server is done via AppleTalk.
According to email that I received from Momentum, the next version of
ScriptLink will support serial connections, modems and wireless technologies
such as Mobitex and RAM. Also in development is a version of ScriptLink that
supports the ETE Communicator (a combination cellular phone, fax machine and
global positioning system for the Newton). If this technology becomes a
reality, Newton will be the leading PDA with true wireless technology. 
	I happen to have PhotonicUs wireless networking hardware in my apartment.
ItUs designed to give Macintoshes wireless AppleTalk networking capabilities.
[See Vernon HuangUs review of the Photonics hardware elsewhere in this issue.
Ed.] Since I have a battery pack for one of the transceivers, I decided to
plug it in to the Newton and give ScriptLink a whirl. Without so much as a
whimper, the two (ScriptLink software and Photonics hardware) worked
flawlessly together, at least with the samples I tried. I must admit its very
satisfying to sit across a room with a Newton, push a button and watch a
Macintosh go into action.

Testing 1, 2 ,3
Momentum includes three samples programs complete with source code (bonus!).
They range in complexity from beginner to intermediate. The first sample
contains three buttons along the bottom of the application (see Figure 2).
The buttons make a connection with a ScriptLink server, send some AppleScript
code and disconnect. The window above the buttons displays any returned data
that results from running an AppleScript. 
	I used this sample of code to try some AppleScripts of my own. Though I
am new to AppleScript, with the help of Danny GoodmanUs The Complete
AppleScript Handbook I created some useful scripts that I tested successfully
with ScriptLink.
	All AppleScript code should be created using AppleUs Script Editor. Once
you are sure it works, then fire up NTK to insert the code into a package.
The easiest way to create AppleScript on the Newton is to place the code in
its own slot in the base view. Subsequently, when you call the function to
send the script, you reference the slot where the code resides. Currently,
ScriptLink supports scripts of less than 2K in size. If you need to execute
longer scripts, you must break them down into smaller pieces, each within its
own slot. Version 1.1 of ScriptLink will allow packet sizes of up to 32K,
removing this barrier. Momentum said that the new version will be available
at no cost for registered users of version 1.0.
	All of the code that I tried worked without incident. The ScriptLink
client functions and sample code performed well. In fact, I believe you need
to look at the ScriptLink server on the Mac as the weakest link. Since it is
responsible for handling multiple Newton requests and the compilation and
execution of AppleScripts, I looked for problems within that program. From
what I could discern, it ran well. 

So WhatUs Wrong With It?
The question isnUt so much RWhatUs wrong with ScriptLink,S its RWhat else
could have been included?S The 2K packet limit is frustrating, but that
problem will be resolved with the next release. There is no way to send a
graphics file from a Mac to a Newton. If your application queries a database
and the result is an image of some sort, thereUs no simple way to get that
picture or graph to the Newton. The gentleman I received email from at
Momentum said he would mention that problem to the development team. Keep
your fingers crossed.

In Summary
Would it be too bold to say that ScriptLink is the most significant product
for the Newton since the introduction of the Newton? In one fell swoop, the
NewtonUs memory constraints have been indirectly eliminated. You now have
access to any scriptable database, spreadsheet, word processor or other
application. You have the freedom of remotely uploading and downloading
information to and from Macintoshes using an understandable, but robust
scripting language. The power to bypass the Newton Connection Kit for data
transfers is yours. Any application that you write for the Newton can now
have its data sent directly to any scriptable Mac application. 
	At the beginning of this article, before I reviewed this product, I
stated that ScriptLink could single-handedly create new software companies.
After completing this review I believe that this is true. I know I have at
least have a dozen ideas for vertical applications in mind as I write this.
Excuse me while I continue with my AppleScript lessons Psoftware glory
awaits. 

Scott is a recent graduate of the University of Michigan with a degree in
Computer Engineering. He is currently working at Procter and Gamble as an
internal consultant for the finance and accounting department, supporting
their PCs and technology needs. Scott spends his spare time programming the
Newton, weightlifting, in-line skating, reading and playing tennis with
friends.

